import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wangxin
 * Date: 2024-08-14
 * Time: 20:20
 */
public class Demo9 {
    public static void main(String[] args) throws IOException {
//        File f = new File("output.txt");
//        f.createNewFile();
//       try(OutputStream outputStream = new FileOutputStream("output.txt")){
//           outputStream.write('h');
//           outputStream.write('e');
//           outputStream.write('l');
//           outputStream.write('l');
//           outputStream.write('o');
//           outputStream.flush();
//       }
//    File f = new File("output.txt");
//    try(OutputStream outputStream = new FileOutputStream("output.txt")){
//        byte[] buf = new byte[]{
//            (byte)'G',(byte) 'o',(byte) 'o',(byte) 'd'
//        };
//        outputStream.write(buf);
//        outputStream.flush();
//    }
//        File f = new File("output.txt");
//        try(OutputStream outputStream = new FileOutputStream("output.txt")){
//            byte[] buf = new byte[]{
//                    (byte)'G',(byte) 'o',(byte) 'o',(byte) 'd',(byte)'G',(byte) 'o',(byte) 'o',(byte) 'd'
//            };
//            outputStream.write(buf,3,4);
//            outputStream.flush();
//        }
//        File f = new File("output.txt");
//        try(OutputStream outputStream = new FileOutputStream("output.txt")){
//           String s = "nothing";
//            outputStream.write(s.getBytes());
//            outputStream.flush();
//        }
        File f = new File("output.txt");
        try(OutputStream outputStream = new FileOutputStream("output.txt")){
            String s = "你好中国";
            outputStream.write(s.getBytes("UTF-8"));
            outputStream.flush();
        }
    }
}
